home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / telecom / 146 / gfa / shellint.c < prev    next >
Encoding:
Text File  |  1987-06-17  |  640 b   |  26 lines

  1. /*****************************************************************************
  2. *
  3. * shell sort function for INTEGERS -  Array%()  
  4. * For interface with GFA Basic 
  5. * Program by John Tal of MichTron Inc.
  6. *
  7. *****************************************************************************/
  8.  
  9. shell(array,elements)
  10. long array[];
  11. int elements;
  12. {
  13.  int gap,i,j;
  14.  long temp;
  15.  
  16.  for(gap = elements/2 ; gap > 0; gap /= 2)
  17.     for(i = gap; i < elements; i++)
  18.       for(j = i-gap; j >= 0 && array[j] > array[j + gap]; j-= gap)
  19.       {
  20.        temp = array[j];
  21.        array[j] = array[j + gap];
  22.        array[j + gap] = temp;
  23.       }
  24.  
  25. }
  26.